;(async function (){
    const express = require("express")   
    const db = require("./db/db")
    const logicRoute = require("./routes/logicRoute")
    const uiRoute = require("./routes/uiRoute")
    try{
        await db
        console.log("数据库连接成功")
        const app = express()
        app.use(express.static("./web"))
        app.use(express.urlencoded({extended: false}))
        app.use(logicRoute)
        app.use(uiRoute)
        app.set("view engine","ejs")
        app.set("views","../04-设置ejs/template")
        app.listen(5000,(err)=>{
            if(err) console.log("服务器访问失败")
            else console.log("服务器访问成功")
        })
    }catch(err){
        console.log("数据库连接失败")
    }
})()